Skip to content

feat(generation): align validated SSE adapter with backend tasks - #110

Open
xyh202131 wants to merge 3 commits into
1024XEngineer:mainfrom
xyh202131:feat/generation-sse-adapter
Open

feat(generation): align validated SSE adapter with backend tasks#110
xyh202131 wants to merge 3 commits into
1024XEngineer:mainfrom
xyh202131:feat/generation-sse-adapter

Conversation

@xyh202131

@xyh202131 xyh202131 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

本次更新

  • Generation Task 使用带鉴权的 fetch SSE 接收状态,不再依赖无法设置请求头的 EventSource。
  • 同时兼容后端事件字段 id 和旧字段 task_id,统一转换为前端 taskId
  • SSE 路由返回 404 时才回退任务查询;其他错误原样上报,不静默降级。
  • 支持取消订阅、401 恢复与流式分块解析。
  • 动作生成保留首帧 1 帧、完整动画 32 帧的输入契约。

验证

  • TypeScript 类型检查通过。
  • oxlint 通过。
  • 全量前端测试:26 files / 161 tests 通过。
  • 生产构建通过。

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
windup Ready Ready Preview Aug 8, 2026 11:43am

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary: two issues stand out.

Findings without inline locations

  • frontend/src/entities/generation/index.ts:102: The complete-animation result type only preserves URLs, but the backend action frame DTO already carries duration_ms and the frontend Frame model can store durationMs. Once this adapter maps the task into GenerationResult, that timing data is gone and downstream character writes will have to invent defaults.

Comment thread frontend/src/entities/generation/api.ts
@johnnyzhang-eng

Copy link
Copy Markdown

实测反馈:契约对得上,但终态不关流会无限重连;另外目前零 UI 消费者

在集成分支(main + #117 + #119 + #111 + 本 PR)上验证,并对一台真实部署的后端订阅了一个已完成的任务。

1. 契约是对的,两处可以放心

  • 事件名:服务端实际只吐一种事件名 task_update,靠 payload 里的 status 区分状态,payload 五个键 task_id / task_type / status / result / error_message。本 PR 只监听 task_update 是对的。
    ⚠️ 注意另有一份设计文档写的是 status / progress / completed / failed 四个事件名,与线上实际行为不符,别照那份改。
  • URL 拼接带了 project_id,与后端强制要求的 query 参数一致。

2. 终态之后 EventSource 会每 3 秒重连一次,需要显式 close

服务端发完终态事件就关流,但响应里带了 retry: 3000。浏览器原生 EventSource 把「连接关闭」当成断线,于是按 retry 间隔重连——实测 45 秒内重连 15 次,每次都重新收到同一条 completed 事件,测试结束时强制 close,readyState 仍停在 CONNECTING。

也就是说:任务早就结束了,前端还在每 3 秒打一次请求,且业务回调会被重复触发。

修法二选一(前者更稳):

  • 前端在收到 status 为终态(completed / failed)时显式 es.close()
  • 或服务端在关流前不下发 retry,改用一个明确的终止事件。

3. 目前全仓没有调用方

createGenerationApis 的调用点,除测试外为 0。要接进界面还差组合根注入四样:baseUrluserIdtransport: { request, stream }(需要把 #117 的 client 与 shared/api/stream.tssubscribeToEventStream 适配进来)、resolveImageSize(projectId)。这一层目前没人认领,本 PR 合了之后界面上仍然摸不到。

@xyh202131
xyh202131 force-pushed the feat/generation-sse-adapter branch from 33b4863 to d8d171b Compare August 8, 2026 08:11
@xyh202131 xyh202131 changed the title feat(generation): add validated SSE task adapter feat(generation): align validated SSE adapter with backend tasks Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants